﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 花店管理系统.start
{
    public partial class Person : Form
    {
        public Person()
        {
            InitializeComponent();
        }

        private void Person_Load(object sender, EventArgs e)
        {
            DB.GetCn();
            string str = "select * from Twoker where t_name='" + Login.username + "'";
            DataTable dt = DB.GetDataSet(str);
            txtId.Text = dt.Rows[0][0].ToString();
            txtName.Text = dt.Rows[0][1].ToString();
            txtSex.Text = dt.Rows[0][2].ToString();
            dtpBirth.Value = Convert.ToDateTime(dt.Rows[0][10]);
            dtpHire.Value = Convert.ToDateTime(dt.Rows[0][9]);
            txtAddess.Text = dt.Rows[0][6].ToString();
            txtPhone.Text = dt.Rows[0][7].ToString();
            txtWages.Text = dt.Rows[0][4].ToString();
            txtDepartment.Text = dt.Rows[0][5].ToString();
            txtretumes.Text= dt.Rows[0][8].ToString();
            DB.cn.Close();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            DB.GetCn();
            string str = NewMethod();
            DB.SqlEx(str);
            MessageBox.Show("修改成功");
            DB.cn.Close();

            string NewMethod()
            {
                return "update Twoker set t_name='"
                                + txtName.Text + "',sex='"
                                + txtSex.Text + "',shengri='"
                                + dtpBirth.Value + "',ruzhiriqi='"
                                + dtpHire.Value + "',w_add='"
                                + txtAddess.Text + "',phone='"
                                + txtPhone.Text + "',saler="
                                + Convert.ToInt32(txtWages.Text) + ",department='"
                                + txtDepartment.Text + "',gerenjiesao='"
                                + txtretumes.Text + "' where W_id=" + Convert.ToInt32(txtId.Text) + "";
            }
        }

        private void btnCance_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
